#include <cstdio>
#include <cstring>
bool hash[128] = {false};
//memset(hash,false,sizeof(hash));//不可以放在函数外
int main()
{
    char *line = NULL;
    // size_t len;
    unsigned long int len;
    len = getline(&line, &len, stdin);
    line[len--] = 0; //删掉结尾的'\n'
    for (int i = 0; i < len; ++i)
    {
        hash[line[i]] = true;
    }
    len = getline(&line, &len, stdin);
    line[len--] = 0;
    for (int i = 0; i < len; ++i)
    {//分三种情况，前两种不输出
        if (hash['+'] && (line[i] >= 'A' && line[i] <= 'Z'))
        {
            continue;
        }
        else if ((line[i] >= 'a' && line[i] <= 'z') && true == hash[line[i] - 32])
        {
            continue;
        }
        else if (false == hash[line[i]])
        {
            putchar(line[i]);
        }
    }
    putchar('\n');
    return 0;
}